﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using RapidWebDev.Platform;
using System.Collections.ObjectModel;
using System.ServiceModel.Web;
using TestCenter.Platform.DataModel;
using RapidWebDev.Common.Web.Services;
using System.Runtime.Serialization;
using AjaxControlToolkit;

namespace TestCenter.Platform.Services
{
    [ServiceContract(Name = "ApplicationService", SessionMode = SessionMode.Allowed)]
    public interface ITestCenterServices
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentId"></param>
        /// <param name="testCenterHierarchyType"></param>
        /// <returns></returns>
        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat=WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/GetChildrenTreeNode")]        
        Collection<HierarchyDataObject> GetChildrenTreeNode(SearchCondition condition);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="parentId"></param>
        /// <returns></returns>
        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/GetAllProjects/{parentId}")]
        Collection<HierarchyDataObject> GetAllTestSuiteUnderTestProject(string parentId);
        /// <summary>
        /// 
        /// </summary>
        /// <param name="post"></param>
        /// <returns></returns>
        [OperationContract]
        [WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/SaveTestSuite")]
        string SaveTestSuite(TestSuitePost post);

        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "json/GetTestPlans")]
        Collection<TestPlanJson> GetTestPlans();


        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/GetBuilds/{PlanId}")]
        Collection<HierarchyDataObject> GetBuilds(string PlanId);


        [OperationContract]
        [WebInvoke(Method = "GET", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "json/GetTestCaseSuitesInTestPlan/{projectId}/{planId}")]
        Collection<HierarchyDataObject> GetTestCaseSuitesInTestPlan(string projectId, string planId);


    }

    [Serializable]
    [DataContract]
    public class TestPlanJson
    {
        [DataMember]
        public Guid TestPlanId { get; set; }

        [DataMember]
        public string Name { get; set; }
    }

    [Serializable]
    [DataContract]
    public class SearchCondition
    {
        [DataMember]
        public string parentId{get;set;}

        [DataMember]
        public string testCenterHierarchyType { get; set; }
    }


    [Serializable]
    [DataContract]
    public class TestSuitePost
    {
        [DataMember]
        public string Name { get; set; }

        [DataMember]
        public string Summary { get; set; }

        [DataMember]
        public string ParentId { get; set; }
    }
}
